package com.guowen.myaccount;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.guowen.myaccount.db.AccountBean;

import java.io.Serializable;

public class AccountContextActivity extends AppCompatActivity implements View.OnClickListener{

    private TextView moneyTv, typeNameTv, kindTv, acconutTv, timeTv, beizhuTv;
    private ImageView typeImageIv, backIv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_account_context);

        moneyTv = findViewById(R.id.activity_acccon_tv_money);
        typeNameTv = findViewById(R.id.activity_acccon_tv_typename);
        kindTv = findViewById(R.id.activity_acccon_tv_kind);
        acconutTv = findViewById(R.id.activity_acccon_tv_account);
        timeTv = findViewById(R.id.activity_acccon_tv_time);
        beizhuTv = findViewById(R.id.activity_acccon_tv_beizhu);
        backIv = findViewById(R.id.activity_acccon_title_iv);
        typeImageIv = findViewById(R.id.activity_acccon_iv_typeimage);

        backIv.setOnClickListener(this);

        Intent intent = getIntent();
        AccountBean click_bean = (AccountBean) intent.getSerializableExtra("click_bean");

        moneyTv.setText(click_bean.getMoney()+"");
        typeNameTv.setText(click_bean.getTypename());
        int kind = click_bean.getKind();
        if (kind == 0){
            kindTv.setText("支出");
        }else{
            kindTv.setText("收入");
        }
        acconutTv.setText(click_bean.getAccount());
        timeTv.setText(click_bean.getTime());
        String beizhu = click_bean.getBeizhu();
        if (beizhu != null && !beizhu.isEmpty()){
            beizhuTv.setText(beizhu);
        }else{
            beizhuTv.setText("未填写");
        }
        typeImageIv.setImageResource(click_bean.getsImageId());

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.activity_acccon_title_iv:
                finish();
                break;
        }
    }
}